var backBtn = null;
var LocString = String(window.document.location.href);
function GetQueryString(name) {
	var rs = new RegExp("(^|)" + name + "=([^&]*)(&|$)", "gi").exec(LocString), tmp;
	if (tmp = rs) {
		return decodeURI(tmp[2]);
	}
	// parameter cannot be found
	return "";
}



$(function(){
	var	userCode = $("#userCode");
	var	userName = $("#userName");
	var	gender = $("#gender");
	var	birthday = $("#birthday");
	var	phone = $("#phone");
	var	address = $("#address");
	var userRole = $("#userRole");


	$.get("user/"+GetQueryString("userId"),function (data) {
		if (data.code===200){
			let sex = "女";
				var user = data.data;
				if (user.gender===2){
					sex="男"
				}
				userCode.html(user.userCode)
				userName.html(user.userName)
				gender.html(sex)
				birthday.html(datetime(new Date(user.birthday)))
				phone.html(user.phone)
				address.html(user.address)
				userRole.html(user.roleName)
		}else {
			alert("查看出问题了1")
		}
	})

	function datetime(date) {
		var date1 = new Date();
		return date1.getFullYear() - date.getFullYear()
	}










	backBtn = $("#back");
	backBtn.on("click",function(){
		//alert("view : "+referer);
		if(referer != undefined 
			&& null != referer 
			&& "" != referer
			&& "null" != referer
			&& referer.length > 4){
		 window.location.href = referer;
		}else{
			history.back(-1);
		}
	});
});